#ifndef _VIDEOENCODE_H
#define _VIDEOENCODE_H
#include <GL/glut.h>
#include <GL/gl.h>
//#define __STDC_CONSTANT_MACROS 
extern "C" { 


#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/mathematics.h>
#include <libswscale/swscale.h>
}

class VideoEncode {
  GLbyte	*pBits;
  GLint 	iViewport[4];
  GLenum 	lastBuffer;
  AVCodec 	*codec;
  AVCodecContext *c;
  AVFrame 	*picture;
  AVFrame 	*pictYUV;
  struct SwsContext *img_convert_ctx;
  FILE 		*f;
  uint8_t 	*outbuf;
  uint8_t 	*pictYUV_buf;
  int		outbuf_size;
  int		out_size;
  int		size;
  int		frameno;
  bool		m_recording;
  
  
public:
  VideoEncode();
  void init(char *filename,int w, int h);
  void recFrame(void);
  void stop(void);
  
  int GrabScreenTGA(const char *szFileName);
  int GrabScreenJPG(const char *szFileName,int quality=75);
};


#endif
